﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Core;
using System.Data;

namespace DataAccess.Classes
{
    public class Bill
    {
        #region Anh xa cac cot trong bang => thuoc tinh
        private int _Ma;

        public int Ma
        {
            get { return _Ma; }
            set { _Ma = value; }
        }

        private int _cnt;

        public int cnt
        {
            get { return _cnt; }
            set { _cnt = value; }
        }


        #endregion

        public static List<Bill> All()
        {
            IDataReader reader = null;
            try
            {

                reader = DataProvider.Instance.ExecuteReader("ThanhToan_All");

                return CBO.FillCollection<Bill>(reader);
            }
            catch
            {
                if (reader != null && reader.IsClosed == false)
                    reader.Close();
                return new List<Bill>();
            }
        }

        public static bool Delete(string ma)
        {
            try
            {
                int rs = DataProvider.Instance.ExecuteNonQuery("ThanhToan_Xoa", ma);
                return rs > 0;
            }
            catch
            {
                return false;
            }
        }

        public static bool Pay(string ma)
        {
            try
            {
                int rs = DataProvider.Instance.ExecuteNonQuery("ThanhToan_Pay", ma);
                return rs > 0;
            }
            catch
            {
                return false;
            }
        }

    }
}
